package com.corgi.mybatis.base;

import java.security.SecureRandom;
import java.util.Optional;

/**
 * @title: DefaultIntegerFieldEncryptStrategy
 * @description: 默认整型加密策略 返回范围内的随机数
 * @author: dengmiao
 * @create: 2019-10-18 17:14
 **/
public class DefaultIntegerFieldEncryptStrategy implements EncryptFieldStrategy<Integer> {

    @Override
    public Integer encrypt(Integer source) {
        return Optional.of(source).map(s -> new SecureRandom().nextInt(s)).orElse(null);
    }
}
